\begin{tikzpicture}[>=Stealth, scale=0.5,
    every node/.style={fill=white, inner sep=1pt},
]
    \draw [->] (-5, 0) -- (5, 0) node[below=0.2em] {$x$};
    \draw [->] (0, -1) -- (0, 4) node[left=0.2em]  {$y$};
    \draw (0, 0) node [below left=0.3em] {\small $O$};
    \foreach \x in {-4, ..., -1} {
        \draw (\x, 0.2) -- (\x, 0);
    }
    \foreach \y in {1, ..., 3} {
        \draw (0, \y) -- (-0.2, \y);
    }

    \draw[domain=-5:3,  samples=5] plot (\x, {\x/2 + 2}) (2, 2) node [below] {$y = \frac{1}{2}x + 2$};
    \draw [fill=black] (0,  2) circle(0.1) node[above left=0.3em] {\small $A$};
    \draw [fill=black] (-4, 0) circle(0.1) node[below=0.3em] {\small $B$};
\end{tikzpicture}

